﻿using System;
using System.Linq;

namespace SacNetUG.Models.ViewModels.Home
{
    public class IndexViewModel
    {
        public string Date { get; private set; }
        public string Name { get; set; }
        public string Presenter { get; private set; }

        public IndexViewModel(Event ev)
        {
            Date = ev.StartDate.ToShortDateString();
            Name = ev.Name;
            
            //Let's get a little Func-y!
            Presenter = ev.EventPresenters
                .Aggregate(string.Empty, (presenter, eventPresenter) => presenter += string.Format("{0} & ", eventPresenter.User.Name));

            Presenter = Presenter.TrimEnd(new[] { ' ', '&' });
        }
    }
}
